<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&amp;language=<?php echo $this->userLanguage ?>"></script>
<script type="text/javascript">
window.addEvent("load", function(){
  $$('li.tab_layout_gmapsprofile_places_friends').addEvent('click', function(){
      if (!is_load_friends) {
	    initialize_friends();
		is_load_friends = true;
	  }	
  });
});
</script>
<ul>
  <li>
	<div id="map_canvas_friends"></div>
  </li>
</ul>

<script type="text/javascript">
var is_load_friends=false;
function initialize_friends() {
	   $('map_canvas_friends').set('style', 'width:'+$('map_canvas_friends').offsetWidth+'px');
	   $('map_canvas_friends').set('style', 'height:'+$('map_canvas_friends').offsetWidth+'px');
	   geocoder_friends = new google.maps.Geocoder();
       var latlng_friends = new google.maps.LatLng(40.7406578, -74.0020894);
       var myOptions_friends = {
               zoom: <?php echo $this->scale ?>,
               center: latlng_friends,
			   disableDefaultUI: false,
               mapTypeId: google.maps.MapTypeId.<?php echo $this->map_type ?>
       };
       map_friends = new google.maps.Map(document.getElementById("map_canvas_friends"), myOptions_friends);
	   
  <?php foreach( $this->friends as $membership ):
    if( !isset($this->friendUsers[$membership->resource_id]) ) continue;
    $member = $this->friendUsers[$membership->resource_id];
	$params_member = $this->gmapsprofileFields($member);
	$online_member = $this->gmapsprofileOnline($member);
	$point = ', ';
	if (empty($params_member['gender']) || empty($params_member['birthdate'])) $point="";	
	  $gender_bd = $this->translate(strtolower($params_member['gender'])).$point.$params_member['birthdate'];	

	if( $online_member != 0 )
	  $online = "<div class=online_user_small>".$this->translate('Online')."</div>";
	else 
	  $online = "<div class=offline_user_small>".$this->translate('Offline')."</div>";   
	  
	$compose = '';
	$friend = '';
	$block = '';
	$report = '';
	if( $this->viewer()->getIdentity() )
      $compose = $this->gmapsprofileCompose($member);
    if( $this->viewer()->getIdentity() )
      $friend = $this->gmapsprofileFriendship($member);
    if( $this->viewer()->getIdentity() )
	  $block = $this->gmapsprofileBlock($member);
 	if( $this->viewer()->getIdentity() )
      $report = $this->gmapsprofileReport($member);	  
	  
	$content_info = '<table width=200px border=0 cellpadding=3><tr><td width=50px><div class=icon_small_user>'.$this->htmlLink($member->getHref(), $this->itemPhoto($member, "thumb.icon")).$online.'</div></td><td valign=top style=padding-left:5px;><span class=displayname_user>'.$this->htmlLink($member->getHref(), $member->getTitle()).'</span><br /><span class=gender_user>'.$gender_bd.'</span><br /><span class=location_user>'.$params_member["location"].'</span><br /><div class=link_members_gmap>'.$compose.$friend.$block.$report.'</div></td></tr></table>';
    ?>
  	var infowindow<?php echo $member->user_id ?> = new google.maps.InfoWindow({
	  content: '<?php echo $content_info ?>',
	  disableAutoPan: false,
	});
    geocoder_friends.geocode( { 'address': '<?php echo $params_member["location"] ?>'}, function(results, status) {
      if (status == google.maps.GeocoderStatus.OK) {
        map_friends.setCenter(results[0].geometry.location);
		var marker<?php echo $member->user_id ?> = new google.maps.Marker({
		    position: results[0].geometry.location,
		    map: map_friends,
			icon: 'http://www.google.com/mapfiles/markerF.png' 
		});
	    google.maps.event.addListener(marker<?php echo $member->user_id ?>, 'click', function() {
	  	    infowindow<?php echo $member->user_id ?>.open(map_friends,marker<?php echo $member->user_id ?>);
	    });			
      }
    });
<?php endforeach; ?>
}
window.addEvent('domready', function() {
    initialize_friends();
});

</script>
